
<script type="text/javascript" src="@{'/public/javascripts/jquery-1.6.4.min.js'}"></script>
<script charset="utf-8" src="@{'/public/javascripts/edit_tools/kindeditor-4.0.1/kindeditor-min.js'}"></script>
<script charset="utf-8" src="@{'/public/javascripts/edit_tools/kindeditor-4.0.1/lang/zh_CN.js'}"></script>

<script type="text/javascript">
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[id="newDet"]', {
			resizeType : 2,
			allowPreviewEmoticons : false,
			allowImageUpload : false,
			items : [
				'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image', 'link','table','map','|','source','fullscreen' ]
		});
		    if(${news.newTyp} == 0){
             $("#o1").attr("selected",true);
          }else{
             $("#o2").attr("selected",true);
             $("#Det").hide();
          }
	});
	function editor_add_html(txt){
		// 取得HTML内容
		var htmlX = editor.html();
		// 设置HTML内容
		//editor.html( htmlX + "<br>" + txt );
		//将指定的HTML内容添加到编辑区域的最后位置。
		//editor.appendHtml(txt);
		//插入内容
		editor.insertHtml(txt);
	}
</script>
<script type="text/javascript">
function lan(aaa){
        $.ajax({
               type:"POST",
               url:"@{ProgramaAction.test()}",
               dataType:"json",
               data:"id="+$(aaa).val(),
               success:function(data){
               if(data[0].id != "non"){
                   var opt = "";
	               for(var i=0;i<data.length;i++){
	                  if(opt == ""){
	                    opt = "<option value="+data[i].id+">"+data[i].proName+"</option>";
	                  }else{
	                    opt += "<option value="+data[i].id+">"+data[i].proName+"</option>";
	                  }
	               }
	                 $(aaa).nextAll().remove();
	                 $(aaa).after("&nbsp;&nbsp;<select name='proId' onchange='lan(this);'><option>请选择：</option>"+opt+"</select>");
               }else{
                     $(aaa).nextAll().remove();
               }
               }
        });
 }
</script>


<script type="text/javascript">
    $(function(){
    var i = ${news.newSta};
        if(i == 0){
           $("#o1").attr("selected","selected");
        }else if(i == 1){
           $("#o2").attr("selected","selected");
        }else{
           $("#o3").attr("selected","selected");
        }
    })
    $(function(){
    
    
          if(${news.newSta == 1}){
              $("#sta").attr("checked",true);
          }
    
          $("#dian").bind("blur",function(){
             if(isNaN($("#dian").val()))
             {
             alert("必须是数字");
             $("#dian").attr("value","");
             }
          })
          
          $("#xin").change(function(){
            if($(this).val()==0){
                 $("#Det").show();
            }else{
                 $("#Det").hide();
            }
          })
          
                    
          $("#bt1").click(function(){
          $("#newTag").val("");
          if($("#div1").is(":hidden")){
             $("#div1").show();
          }else{
             $("#div1").hide();
          }
          })

          $("#bt2").click(function(){
          var la = "";
          var i = 0;
             $("input[type='checkbox']:checked").each(function(){
             if(i == 0){
             }else if(i == 1){
                       la = $(this).val();
             }else{
                       la = la+","+$(this).val();
             }
                 i++;
             });
          var aa = $("#newTag").val();
          if(aa == ""){
               aa = la;
          }else if(la == ""){
          }else{
              aa = aa+","+la;
          }
          $("#newTag").val(aa);
          $("#div1").hide();
          })
    })
</script>

<form action="@{save()}" method="post">
  #{if flash.success}
  <p><font color="red">${flash.success}</font></p>
  #{/if}
  <p>请选择所属栏目：
	<select name="proId" onchange="lan(this);">
	          <option value=${news.programa?.id}>${news.programa?.proName}</option>
			#{list items:programas,as:'programa'}
			#{if news.programa.id != programa.id}
			  <option value=${programa.id}>${programa.proName}</option>
			 #{/if}
			#{/list}
    </select>
  </p>
  <p>新闻标题：<input type="text" name="news.newTit" value=${news.newTit}>
             <input type="hidden" name="news.id" value=${news.id}>
  </p>
  <p>新闻代码：<input type="text" name="news.newCode" value=${news.newCode}></p>
  <p>来&nbsp;&nbsp;&nbsp;&nbsp;源：<input type="text" name="news.newSou" value=${news.newSou}></p>
  <p>关&nbsp;键&nbsp;字：<input type="text" name="news.newKws" value=${news.newKws}></p>
  <p>点&nbsp;击&nbsp;量：<input id="dian" type="text" name="news.newHits" value=${news.newHits} style="width: 50px"></p>
  <p>状&nbsp;&nbsp;&nbsp;&nbsp;态：<input type="checkbox" value="1" name="news.newSta" id="sta">新闻置顶</p>
  <p>类型：<select id="xin" name="news.newTyp">
               <option value="0" id="o1">普通新闻</option>
               <option value="1" id="o2">标题新闻</option>
          </select>
  </p>
  <p>标签选择：<input type="text" name="news.newTag" value=${news.newTag} id="newTag">
             <input type="button" value="选择" id="bt1">
  </p>
  <div STYLE="border-style:solid;border-width:1pt; border-color:green;width: 41%;display: none;" id="div1">
  <p>
         <input type="checkbox" value="资讯">资讯
         <input type="checkbox" value="11">11
         <input type="checkbox" value="22">22
         <input type="checkbox" value="33">33
         <input type="checkbox" value="新书">新书
         <input type="checkbox" value="最新">最新
         <input type="checkbox" value="ss">ss
         <input type="checkbox" value="99">99
         <input type="checkbox" value="88">88
         <input type="checkbox" value="00">00<br/>
         <input type="checkbox" value="新闻">新闻
         <input type="checkbox" value="热门">热门
         <input type="checkbox" value="头条">头条
         <input type="checkbox" value="44">44
         <input type="checkbox" value="44">44
         <input type="checkbox" value="44">44
         <input type="checkbox" value="44">44
         <input type="checkbox" value="4g">4g
         <input type="checkbox" value="44">44
         <input type="checkbox" value="44">44
  </p>
  <p><input type="button" value="确定" id="bt2"></p>
  </div>
  
  <p id="Det">新闻详情：
  <textarea rows="10" cols="70" id="newDet" name="news.newDet">${news.newDet}</textarea>
  </p>
  <p><input type="submit" value="更新"></p>
</form>
